package com.kingzoon.seckill.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kingzoon.seckill.dto.Result;
import com.kingzoon.seckill.enums.MacroDefine;
import com.kingzoon.seckill.service.MemberRegisterService;



@Controller
@Api(value = "注册接口", description = "注册接口")
public class MemberRegisterController {
	
	@Autowired
	private MemberRegisterService memberRegisterService; 
	
	@ApiOperation(value = "用户注册")
	@RequestMapping(value="/register",method=RequestMethod.POST,produces={"application/json;charset=utf-8"})
	@ResponseBody
	public Result<HashMap<String,Object>> login(
			@ApiParam(required = true, value = "平台号")@RequestParam("exchangeId")String exchangeId,
			@ApiParam(required = true, value = "商户号")@RequestParam("distributorId")String distributorId,
			@ApiParam(required = true, value = "登录账号")@RequestParam("account")String account,
			@ApiParam(required = true, value = "短信验证码")@RequestParam("smsCode")String smsCode,
			@ApiParam(required = true, value = "登录密码")@RequestParam("password")String password){
		Result<HashMap<String,Object>> rs = new Result<HashMap<String,Object>>(false, MacroDefine.JC_CODE.R_9999.getCode(), MacroDefine.JC_CODE.R_9999.getMessage());
		try {
			/*			if(LoginHelper.Login(account, password)){
			}*/
			HashMap<String,Object> mapParam = new HashMap<String,Object>();
			mapParam.put("exchangeId", exchangeId);
			mapParam.put("distributorId", distributorId);
			mapParam.put("phoneNo", account);
			mapParam.put("smsCode", smsCode);
			mapParam.put("password", password);
			rs = memberRegisterService.doBusiness(mapParam, rs);
			return rs;
		}
		catch (Exception e) {
			e.printStackTrace();
			return rs;
		}
	}

}
